/*
 * Thread.cpp
 *
 *  Created on: 30/04/2011
 *      Author: dela
 */

#include "Thread.h"

/**
 *
 */
void Thread::join() {
	pthread_join(this->thread, NULL);
}

/**
 *
 */
void Thread::start() {
	pthread_create(&this->thread, NULL, starter, this);
}

/**
 *
 */
void *Thread::starter(void *data) {
	Thread *t = (Thread*) data;
	t->run();
	return NULL;
}

/**
 *
 */
bool Thread::isWorking() {
	workingMutex.lock();
	bool aux = working;
	workingMutex.unLock();
	return aux;
}

/**
 *
 */
void Thread::setWorking(bool working) {
	workingMutex.lock();
	this->working = working;
	workingMutex.unLock();
}
